<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="../img/asset-favico.ico">
        <title>登录</title>
        <link rel="stylesheet" href="../css/page-health-login.css" />
        <link rel="stylesheet" href="../plugins/elementui/index.css" />
        <script src="../plugins/jquery/dist/jquery.min.js"></script>
        <script src="../plugins/healthmobile.js"></script>
        <script src="../plugins/vue/vue.js"></script>
        <script src="../plugins/vue/axios-0.18.0.js"></script>
        <script src="../plugins/elementui/index.js"></script>
    </head>
    <body data-spy="scroll" data-target="#myNavbar" data-offset="150">
    <div class="app" id="app">
        <!-- 页面头部 -->
        <div class="top-header">
            <span class="f-left"><i class="icon-back"></i></span>
            <span class="center">智行健康</span>
            <span class="f-right"><i class="icon-more"></i></span>
        </div>
        <div style="margin-left: 20px">手机快速登录</div>
        <!-- 页面内容 -->
        <div class="contentBox">
            <div class="login">
                <form id='login-form'>
                    <div class="input-row">
                        <label>手机号</label>
                        <div class="loginInput">
                            <input v-model="loginInfo.telephone" id='account' type="text" placeholder="请输入手机号">
<!--                            <input id="validateCodeButton" @click="sendValidateCode()" type="button" style="font-size: 12px" value="获取验证码">-->
                            <!--自定义element动态加载效果-->
                            <el-button
                                    type="primary"
                                    @click="sendValidateCode()"
                                    :disabled="disabled=!show"
                                    style="width:40%;font-size:12px; padding: 10px"
                            >
                                <span  v-show="show" >获取验证码</span>
                                <span  v-show="!show" class="count" >{{count}}</span>
                            </el-button>

                        </div>
                    </div>
                    <div class="input-row">
                        <label>验证码</label>
                        <div class="loginInput">
                            <input v-model="loginInfo.validateCode" style="width:80%" id='password' type="text" placeholder="请输入验证码">
                        </div>
                    </div>
                    <div class="input-row" style="font-size: 12px">
                        <input type="checkbox" checked>
                        阅读并同意《智行健康用户协议》《智行健康隐私条款》
                    </div>
                    <div class="btn yes-btn"><a @click="login()" href="#">登录</a></div>
                </form>
            </div>
        </div>
    </div>
    </body>
    <script>
        var vue = new Vue({
            el:'#app',

            data:{
                loginInfo:{},//登录信息
                //预约信息
                //验证码按钮显示
                show: true,
                count: "", // 初始化次数
                timer: null
            },
            methods:{
                //发送验证码
                sendValidateCode() {
                    //获取用户输入的手机号
                    var telephone = this.loginInfo.telephone;
                    if (!checkTelephone(telephone)) {
                        this.$message.error("请输入正确的手机号");
                        return false;
                    }
                    //显示30s倒计时效果
                    let TIME_COUNT = 30; //更改倒计时时间
                    if (!this.timer) {
                        this.count = TIME_COUNT+'s后重新获取';
                        this.show = false;
                        this.timer = setInterval(() => {
                            if (TIME_COUNT > 0 ) {
                                TIME_COUNT--;
                                this.count = TIME_COUNT+'s后重新获取';
                            } else {
                                this.show = true;
                                TIME_COUNT = 5;
                                clearInterval(this.timer); // 清除定时器
                                this.timer = null;
                            }
                        }, 1000);
                    }
                    //发送验证码
                    axios.post("/validateCode/send4Login.do?telephone="+telephone)
                        .then((res)=>{
                            if (!res.data.flag){
                                this.$message.error(res.data.message)
                            }
                        })

                },
                //登录
                login(){
                    var telephone = this.loginInfo.telephone;
                    if (!checkTelephone(telephone)) {
                        this.$message.error('请输入正确的手机号');
                        return false;
                    }
                    axios.post("/member/check.do",this.loginInfo).then((response) => {
                        if(response.data.flag){
                            //登录成功,跳转到member.html
                            window.location.href="member.html";
                        }else{
                            //失败，提示失败信息
                            this.$message.error(response.data.message);
                        }
                    });
                }
            }
        });
    </script>
</html>


















